package CSISL4pk;

import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

public class EditCaseFrame extends JInternalFrame
{

    JButton addCaseButton,submitButton, cancelButton;
    private JLabel caseNumberLabel, CaseDescriptionLabel, addCasePanelTitle, addressLabel,
            streetLabel, cityLabel, stateLabel, zipLabel, firstNameLabel, lastNameLabel,
            crimeTypeLabel, crimeLocationLabel, victimLabel, suspectLabel, witnessLabel,
            investigatorIdLabel, dateLabel;
    JTextField caseNumberField, firstNameField, lastNameField, streetField, cityField,
            stateField, zipField, investigatorIdField, dateMonthField, dateDayField,
            dateYearField, crimeLocationField;
    JTextArea caseDescriptionArea;
    JComboBox crimeTypeBox, locationBox;
    private String[] locations =
    {
        "Avenues", "Sugarhouse", "Liberty East", "Liberty West", "Trolley Square", "Central", "University", "Rose Park", "Glendale", "Foothill", "Capitol Hill", "Downtown"
    };
    private String[] crimeTypeList =
    {
        "ARSON", "ASSAULT", "BATTERY", "BURGLARY", "DUI", "MURDER",
        "THEFT", "VANDALISM"
    };
    //Moved up here to add new windows on top of case window
    JPanel addCasePanel = new JPanel();
    PersonFrame victim, witness, suspect;

    private int addressX, addressY;
    private int caseNumberX, caseNumberY;
    private int caseDescriptionX, caseDescriptionY;
    private int nameX, nameY;
    private int crimeTypeX, crimeTypeY;
    private int vicSusWitX, vicSusWitY;
    private int investigatorIdX, investigatorIdY;
    private int dateX, dateY;
    private int frameType;
    private static int openFrameCount = 0;
    //This will be the temporary variable to hold the object
    Case temp = new Case();

    public EditCaseFrame(int frameType)
    {
        super("New Case: " + (++openFrameCount),
                false, //resizable
                false, //closable
                false, //maximizable
                true);//iconifiable
//set the location of each object group

        caseNumberX = 150;
        caseNumberY = 85;

        caseDescriptionX = 580;
        caseDescriptionY = 140;

        addressX = 150;
        addressY = 180;

        nameX = 200;
        nameY = 440;

        crimeTypeX = 580;
        crimeTypeY = 85;

        vicSusWitX = 150;  //vicSusWit = victims suspects witnesses
        vicSusWitY = 290;

        investigatorIdX = 800;
        investigatorIdY = 85;

        dateX = 330;
        dateY = 85;


        //this.setLayout(null);
        this.setSize(1100, 700);
        this.setLocation(150, 0);
        this.setBackground(Color.black);
        //this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);       

        addCasePanel.setLayout(null);
        addCasePanel.setSize(1500, 900);
        addCasePanel.setLocation(0, 0);
        addCasePanel.setBackground(Color.lightGray);


//case number objects
        caseNumberLabel = new JLabel("Case Number:");
        caseNumberLabel.setSize(100, 30);
        caseNumberLabel.setLocation(caseNumberX - 85, caseNumberY);

        caseNumberField = new JTextField();
        caseNumberField.setSize(80, 30);
        caseNumberField.setLocation(caseNumberX, caseNumberY);


        //case description objects
        CaseDescriptionLabel = new JLabel("Case Description:");
        CaseDescriptionLabel.setSize(100, 30);
        CaseDescriptionLabel.setLocation(caseDescriptionX - 110, caseDescriptionY);

        caseDescriptionArea = new JTextArea("",40,35);
        caseDescriptionArea.setSize(475, 270);
        caseDescriptionArea.setLineWrap(true);
        caseDescriptionArea.setLocation(caseDescriptionX, caseDescriptionY);

//adress objects
        addressLabel = new JLabel("Address:");
        addressLabel.setSize(80, 30);
        addressLabel.setLocation(80, 250);


        streetLabel = new JLabel("Street:");
        streetLabel.setSize(80, 30);
        streetLabel.setLocation(addressX - 45, addressY);

        streetField = new JTextField();
        streetField.setSize(300, 30);
        streetField.setLocation(addressX, addressY);


        cityLabel = new JLabel("City:");
        cityLabel.setSize(80, 30);
        cityLabel.setLocation(addressX - 30, addressY + 30);

        cityField = new JTextField();
        cityField.setSize(150, 30);
        cityField.setLocation(addressX, addressY + 30);


        stateLabel = new JLabel("State:");
        stateLabel.setSize(80, 30);
        stateLabel.setLocation(addressX + 150, addressY + 30);

        stateField = new JTextField();
        stateField.setSize(30, 30);
        stateField.setLocation(addressX+180, addressY + 30);


        zipLabel = new JLabel("Zip:");
        zipLabel.setSize(80, 30);
        zipLabel.setLocation(addressX + 215, addressY + 30);

        zipField = new JTextField("0");
        zipField.setSize(60, 30);
        zipField.setLocation(addressX +240, addressY + 30);


//first and last name objects
        firstNameLabel = new JLabel("First Name:");
        firstNameLabel.setLocation(nameX - 70, nameY);
        firstNameLabel.setSize(100, 30);

        firstNameField = new JTextField();
        firstNameField.setSize(100, 25);
        firstNameField.setLocation(nameX, nameY);


        lastNameLabel = new JLabel("Last Name:");
        lastNameLabel.setLocation(nameX - 70, nameY + 30);
        lastNameLabel.setSize(100, 30);

        lastNameField = new JTextField();
        lastNameField.setSize(100, 25);
        lastNameField.setLocation(nameX, nameY + 30);


//date objects
        dateLabel = new JLabel("Date:");
        dateLabel.setSize(50, 25);
        dateLabel.setLocation(dateX - 40, dateY + 3);

        dateMonthField = new JTextField("0");
        dateMonthField.setSize(35, 30);
        dateMonthField.setLocation(dateX, dateY);

        dateDayField = new JTextField("0");
        dateDayField.setSize(35, 30);
        dateDayField.setLocation(dateX + 35, dateY);

        dateYearField = new JTextField("0");
        dateYearField.setSize(45, 30);
        dateYearField.setLocation(dateX + 70, dateY);


//type of crime objects
        crimeTypeBox = new JComboBox();
        crimeTypeBox.setSize(120, 30);
        crimeTypeBox.setLocation(crimeTypeX, crimeTypeY);

        for (int count = 0; count < crimeTypeList.length; count++)
        {
            crimeTypeBox.addItem(crimeTypeList[count]);
        }

        crimeTypeLabel = new JLabel("Crime Type:");
        crimeTypeLabel.setSize(80, 25);
        crimeTypeLabel.setLocation(crimeTypeX - 75, crimeTypeY + 3);

//Victim, suspect, and witness objects
        
        
        victimLabel = new JLabel("Victim:");
        victimLabel.setSize(60, 25);
        victimLabel.setLocation(vicSusWitX - 60, vicSusWitY - 30);
        
        suspectLabel = new JLabel("Suspect:");
        suspectLabel.setSize(70, 25);
        suspectLabel.setLocation(vicSusWitX - 70, vicSusWitY + 135);
        
        witnessLabel = new JLabel("Witness:");
        witnessLabel.setSize(75, 25);
        witnessLabel.setLocation(vicSusWitX +400, vicSusWitY + 135);
        
        victim = new PersonFrame();
        addCasePanel.add(victim);
        victim.setLocation(vicSusWitX-60,vicSusWitY-5);
        suspect = new PersonFrame();
        addCasePanel.add(suspect);
        suspect.setLocation(vicSusWitX-60,vicSusWitY+160);
        witness = new PersonFrame();
        addCasePanel.add(witness);
        witness.setLocation(vicSusWitX+450,vicSusWitY+160);

        investigatorIdField = new JTextField();
        investigatorIdField.setSize(60, 30);
        investigatorIdField.setLocation(investigatorIdX, investigatorIdY);

        investigatorIdLabel = new JLabel("Investigator ID:");
        investigatorIdLabel.setSize(100, 25);
        investigatorIdLabel.setLocation(investigatorIdX - 90, investigatorIdY + 3);


//single labels

        crimeLocationLabel = new JLabel("Crime Location");
        crimeLocationLabel.setSize(90, 25);
        crimeLocationLabel.setLocation(90, 150);

        locationBox = new JComboBox(locations);
        locationBox.setSize(120, 25);
        locationBox.setLocation(200, 150);

//submit button

        submitButton = new JButton("Submit Form");
        submitButton.setSize(150, 40);
        submitButton.setLocation(380, 600);

//cancel button

        cancelButton = new JButton("Cancel");
        cancelButton.setSize(125, 40);
        cancelButton.setLocation(550, 600);
        addCasePanel.add(cancelButton);

        if (frameType == 1)
            addCasePanelTitle = new JLabel("Edit Case");
        if (frameType == 0)
            addCasePanelTitle = new JLabel("Add Case");
        addCasePanelTitle.setLocation(200, 0);
        addCasePanelTitle.setSize(400, 50);
        Font font = new Font("SansSerif", 1, 30);
        addCasePanelTitle.setForeground(Color.DARK_GRAY);
        addCasePanelTitle.setFont(font);

        //text Areas

        addCasePanel.add(addCasePanelTitle);
        addCasePanel.add(caseNumberLabel);
        addCasePanel.add(caseNumberField);
        //addCasePanel.add(addressLabel);
        addCasePanel.add(streetLabel);
        addCasePanel.add(cityLabel);
        addCasePanel.add(stateLabel);
        addCasePanel.add(zipLabel);
        addCasePanel.add(caseDescriptionArea);
        addCasePanel.add(streetField);
        addCasePanel.add(cityField);
        addCasePanel.add(stateField);
        addCasePanel.add(zipField);
        addCasePanel.add(CaseDescriptionLabel);

        addCasePanel.add(crimeTypeBox);
        addCasePanel.add(crimeTypeLabel);
        addCasePanel.add(crimeLocationLabel);
        addCasePanel.add(locationBox);

        addCasePanel.add(victimLabel);
        addCasePanel.add(suspectLabel);
        addCasePanel.add(witnessLabel);

        addCasePanel.add(investigatorIdLabel);
        addCasePanel.add(investigatorIdField);
        addCasePanel.add(dateMonthField);
        addCasePanel.add(dateDayField);
        addCasePanel.add(dateYearField);
        addCasePanel.add(dateLabel);
 
        addCasePanel.add(submitButton);


        this.add(addCasePanel);

    }
}
